{{--继承模板--}}
@extends('admin.layouts.common')
@section('content')
    <br>
    <div class="layui-anim layui-anim-up">
        <form class="layui-form">
            <input type="hidden" value="{{ isset($info->group_id) ? $info->group_id : '' }}" name="group_id">
            <div class="layui-container">
                <div class="layui-row">
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户组名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" autocomplete="off" placeholder="请输入用户组名" class="layui-input" value="{{ isset($info->group_id) ? $info->title : '' }}" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn layui-btn-black" lay-submit="" lay-filter="groupedit">编辑</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <script src="{{asset('layuiadmin/layui/layui.js')}}"></script>
    <script>
        layui.use(['form','layer'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,$ = layui.jquery;
            var _token =  $('meta[name="csrf-token"]').attr('content');
            //监听提交
            form.on('submit(groupedit)', function(data){
                data.field._token = _token;
                $.post("{{url('admin/auth/groupedit')}}",data.field,function(res){
                    if(res.code == 1){
                        layer.msg(res.msg,function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                },'json')
                return false;
            });
        });
    </script>
@endsection